#include <iostream>
#include <string>

using namespace std;

class Solution {
public:
    int percentageLetter(string s, char letter) {
        // cout << "letter:" << letter << endl;
        int re = 0;
        if (s.size() < 1)
            return re;

        for (size_t i = 0; i < s.size(); ++i) {
            // char c = s[i];
            // // 使用字符c
            // cout << c << endl;
            if (s[i] == letter) {
                re++;
            }
        }        
        // cout << "re:" << re << endl;
        re = re * 100 / s.size();
        return re;
    }
};

// input s = "foobar"
// letter = "o"
// output: 33
void test01() {
    Solution obj;
    cout << "test01 result:" << obj.percentageLetter("foobar", 'o') << endl;
}

// input s = "jjjj"
// letter = "k"
// output: 0
void test02() {
    Solution obj;
    cout << "test02 result:" << obj.percentageLetter("jjjj", 'k') << endl;
}

void testXX() {
    Solution obj;
    cout << "testXX result:" << obj.percentageLetter("", ' ') << endl;
}

int main() {
    test01();
    test02();
    testXX();
    cout << "finish";
    return 0;
}
